package fr.cephb.joperon.structures.bindings;

import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

import fr.cephb.berkeley.baseapi.bindings.AbstractTupleBinding;
import fr.cephb.joperon.core.types.Fid;
import fr.cephb.joperon.structures.SnpMap;

public class SnpMapBinding extends AbstractTupleBinding<SnpMap>
	{
	public SnpMapBinding()
		{
		}

	@Override
	public SnpMap entryToObject(TupleInput r)
		{
		SnpMap o= new SnpMap();
		
		/* p  was declared as a int64_t */
        o.setP( readInt64(r));

	/* q  was declared as a int64_t */
        o.setQ( readInt64(r));

        /* x  was declared as a int64_t */
        o.setX( readInt64(r));

        /* y  was declared as a int64_t */
        o.setY( readInt64(r));

        /* cv  was declared as a int16_t */
        o.setCv( readInt16(r));


        /* mw  was declared as a int16_t */
        o.setMw( readInt16(r));



        /* sc  was declared as a int16_t */
        o.setSc( readInt16(r));



        /* ori  was declared as a int16_t */
        o.setOri(readInt16(r));



        /* cat  was declared as a int16_t */
        o.setCat(readInt16(r));



        /* ver  was declared as a int16_t */
        o.setVer(readInt16(r));


        /* fid  was declared as a char* */
        o.setFid(new Fid(readCString(r)));



        /* ctg  was declared as a char* */
        o.setCtg(readCString(r));
        /* acn  was declared as a char* */
        o.setAcn(readCString(r));
        /* band  was declared as a char* */
        o.setBand(readCString(r));
         /* chr  was declared as a char* */
        o.setChr(readCString(r));
         /* ca  was declared as a char* */
        o.setCa(readCString(r));
         /* ra  was declared as a char* */
        o.setRa(readCString(r));
         /* aa  was declared as a char* */
        o.setAa(readCString(r));
         /* flags  was declared as a char* */
        o.setFlags(readCString(r));
       
		return o;
		}

	@Override
	public void objectToEntry(SnpMap o, TupleOutput output)
		{
		writeInt64(o.getP(),output);
		writeInt64(o.getQ(),output);
		writeInt64(o.getX(),output);
		writeInt64(o.getY(),output);         
		writeInt16(o.getCv(),output);
		writeInt16(o.getMw(),output);
		writeInt16(o.getSc(),output);
		writeInt16(o.getOri(),output);
		writeInt16(o.getCat(),output);
		writeInt16(o.getVer(),output);
		writeCString( o.getFid().getString() ,output);                                                                                          
		writeCString(o.getCtg(),output);
		writeCString(o.getAcn(),output);
		writeCString(o.getBand(),output);
		writeCString(o.getChr(),output);
		writeCString(o.getCa(),output);
		writeCString(o.getRa(),output);
		writeCString(o.getAa(),output);
		writeCString(o.getFlags(),output);
		}

	}
